<template>
  <div>
    <el-dialog title="添加章节"
               :visible.sync="dialogVisible"
               width="30%"
               :show-close="fasle"
               :before-close="handleClose">
      <el-form :model="chapter"
               label-width="120px">
        <el-form-item label="章节标题">
          <el-input v-model="chapter.title" />
        </el-form-item>
        <el-form-item label="章节排序">
          <el-input-number v-model="chapter.sort"
                           :min="0"
                           controls-position="right" />
        </el-form-item>
      </el-form>
      <span slot="footer"
            class="dialog-footer">
        <el-button @click="handleDialogVisible">取 消</el-button>
        <el-button type="primary"
                   @click="saveOrUpdate">确 定</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
export default {
  props: {
    dialogVisible: Boolean,
    chapter: Object
  },
  data() {
    return {

    }
  },
  methods: {
    handleDialogVisible() {
      this.$emit('handleDialogVisible')
    },
    saveOrUpdate() {
      this.$emit('saveOrUpdate', this.chapter)
      this.handleDialogVisible()
    },
    handleClose() {
      this.handleDialogVisible()
    }
  }
}
</script>

<style>
</style>
